package com.sceneworker.monitorpopup;

import java.awt.event.ActionEvent;

import javax.swing.tree.TreePath;

import com.jme.light.DirectionalLight;
import com.jme.light.PointLight;
import com.jme.light.SpotLight;
import com.jme.scene.Spatial;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;

public class LightStateMenu extends BaseMenu {
	
	private static final String ADD_DIRECTIONAL_LIGHT = "Add Directional Light";

	private static final String ADD_SPOT_LIGHT = "Add SpotLight";

	private static final String ADD_POINT_LIGHT = "Add PointLight";
	
	private		LightState			mcl_ls;
	private		Object				mcl_spatial;

	public LightStateMenu(TreePath cl_selectedPath, SceneWorkerPopUp cl_menu) {
		super(cl_menu);
		
		mcl_ls = (LightState)cl_selectedPath.getLastPathComponent();
		mcl_spatial = cl_selectedPath.getParentPath().getLastPathComponent();
		
		buildMenu();
	}

	@Override
	public void actionPerformed(ActionEvent cl_e) {
		if(cl_e.getActionCommand().equals(ADD_DIRECTIONAL_LIGHT)) {
			DirectionalLight		lcl_light = new DirectionalLight();
			mcl_ls.attach(lcl_light);
			((Spatial)mcl_spatial).updateRenderState();
			
			return;
		}
		
		if(cl_e.getActionCommand().equals(ADD_POINT_LIGHT)) {
			PointLight		lcl_light = new PointLight();
			mcl_ls.attach(lcl_light);
			((Spatial)mcl_spatial).updateRenderState();
			
			return;
		}
		
		if(cl_e.getActionCommand().equals(ADD_SPOT_LIGHT)) {
			SpotLight		lcl_light = new SpotLight();
			mcl_ls.attach(lcl_light);
			((Spatial)mcl_spatial).updateRenderState();
			
			return;
		}

	}

	@Override
	protected void buildMenu() {
		mcl_menu.addSeparator();
		mcl_menu.add(buildAMenuItem(ADD_POINT_LIGHT));
		mcl_menu.add(buildAMenuItem(ADD_SPOT_LIGHT));
		mcl_menu.add(buildAMenuItem(ADD_DIRECTIONAL_LIGHT));

	}

}
